package com.mzj.saas.mservice.sys.controller;

import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.sys.service.FieldService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 通讯录信息设置
 */
@Controller
@RequestMapping("/field")
public class FieldController {
    private static final Logger LOG = LoggerFactory.getLogger(FieldController.class);
    @Autowired
    private FieldService fieldService;

    /*
     *显示通讯录字段
     */
    @PostMapping("companyFieldList")
    @ResponseBody
    public ResultBean<Object> companyFieldList(@RequestHeader String accessToken) {
        return fieldService.companyFieldList(accessToken);
    }

    /*
     *新增自定义字段
     */
    @PostMapping("addCompanyField")
    @ResponseBody
    public ResultBean<Object> addCompanyField(@RequestHeader String accessToken, @RequestParam(name = "name", required = false) String name) {
        return fieldService.addCompanyField(accessToken, name);
    }

    /*
     *删除自定义字段
     */
    @PostMapping("deleteCompanyField")
    @ResponseBody
    public ResultBean<Object> deleteCompanyField(@RequestHeader String accessToken, @RequestParam(name = "id", required = false) Long id) {
        return fieldService.deleteCompanyField(accessToken, id);
    }

    /*
     *修改显示状态
     */
    @PostMapping("updateFieldShowStatus")
    @ResponseBody
    public ResultBean<Object> updateFieldShowStatus(@RequestHeader String accessToken, @RequestParam(name = "flag", required = false) Long flag, @RequestParam(name = "id", required = false) Long id, @RequestParam(name = "status", required = false) Integer status) {
        return fieldService.updateFieldShowStatus(accessToken, flag, id, status);
    }

    /*
     *修改必填状态
     */
    @PostMapping("updateFieldMustStatus")
    @ResponseBody
    public ResultBean<Object> updateFieldMustStatus(@RequestHeader String accessToken, @RequestParam(name = "flag", required = false) Long flag, @RequestParam(name = "id", required = false) Long id, @RequestParam(name = "status", required = false) Integer status) {
        return fieldService.updateFieldMustStatus(accessToken, flag, id, status);
    }
}
